package dao;

import common.spring.jdbc.MySQLHelper;
import common.utils.MyMapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import pojo.form.UserSendCountAddForm;

/**
 * Created by asus on 2019/1/29.
 */
@Repository
public class UserSendCountDao {
    @Autowired
    MySQLHelper sqlHelper;

    public int addUserSendCount(UserSendCountAddForm addForm){
        return sqlHelper.simpleInsert("user_send_count", MyMapUtils.beanToMap(addForm,false));
    }

    public Number getUserSendCount(String wxId){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("select count(*) from user_send_count where to_days(createTime) = to_days(now()) and openId=?");
        return sqlHelper.queryForNumber(stringBuilder.toString(),new Object[]{wxId});
    }
}
